﻿// Copyright richyp 2009
using System;
using System.Collections.Generic;
using System.Text;

namespace Richyp.Bodger {
    public class ReplacementGroup {
        public Equipment Default { get; set; }
        private List<Equipment> options = new List<Equipment>();
        public List<Equipment> Options {
            get {
                return this.options;
            }
        }

        private List<Equipment> alternatives = new List<Equipment>();
        public List<Equipment> Alternatives {
            get {
                return this.alternatives;
            }
        }

        public ReplacementGroup(Equipment defaultItem, List<Equipment> options) {
            this.Default = defaultItem;
            this.AddOptions(options);
        }

        public ReplacementGroup(Equipment defaultItem, List<Equipment> options, List<DistinctEntry> distinct) {
            this.Default = defaultItem;
            this.AddOptions(options);
            this.AddDistinctEntries(distinct);
        }

        public List<Equipment> GetAllOptions() {
            List<Equipment> all = new List<Equipment>();
            foreach (Equipment option in this.options) {
                all.Add(option);
            }
            foreach (DistinctEntry entry in this.distinctEntries) {
                foreach (Equipment option in entry.Options) {
                    all.Add(option);
                }
            }
            foreach (Equipment option in this.alternatives) {
                all.Add(option);
            }
            return all;
        }

        private void AddOptions(List<Equipment> options) {
            foreach (Equipment equipment in options) {
                this.options.Add(equipment);
            }
        }

        private void AddDistinctEntries(List<DistinctEntry> distinct) {
            foreach (DistinctEntry entry in distinct) {
                this.distinctEntries.Add(entry);
            }
        }

        List<DistinctEntry> distinctEntries = new List<DistinctEntry>();
        public List<DistinctEntry> DistinctEntries {
            get {
                return this.distinctEntries;
            }
        }
    }

    public class DistinctEntry {
        private List<Equipment> options = new List<Equipment>();
        public List<Equipment> Options {
            get {
                return this.options;
            }
        }
        private int maximum = 1;
        private int requires = 1;
        public int Maximum {
            get {
                return this.maximum;
            }
            set {
                this.maximum = value;
            }
        }
        public int Requires {
            get {
                return this.requires;
            }
            set {
                this.requires = value;
            }
        }
    }
}
